<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>用户管理</title>
		<link rel="stylesheet" href="../../component/pear/css/pear.css" />
	</head>
	<body class="pear-container">
		<div class="layui-card">
			<div class="layui-card-body">
				<form class="layui-form" action="">
					<div class="layui-form-item">
						<div class="layui-form-item layui-inline">
							<label class="layui-form-label">订单编号</label>
							<div class="layui-input-inline">
								<input type="text" name="keywords" placeholder="" class="layui-input">
							</div>
						</div>

						<div class="layui-form-item layui-inline">
							<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="order-query">
								<i class="layui-icon layui-icon-search"></i>
								查询
							</button>
							<button type="reset" class="pear-btn pear-btn-md">
								<i class="layui-icon layui-icon-refresh"></i>
								重置
							</button>
						</div>
					</div>
				</form>
			</div>
		</div>
		<div class="layui-card">
			<div class="layui-card-body">
				<table id="order-table" lay-filter="order-table"></table>
			</div>
		</div>



		<script type="text/html" id="order-bar">
			<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i></button>
		    <button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i></button>
		</script>



		<script type="text/html" id="order-createTime">
			{{layui.util.toDateString(d.createTime, 'yyyy-MM-dd')}}
		</script>

		<script src="../../component/layui/layui.js"></script>
		<script src="../../component/pear/pear.js"></script>
		<script>
			layui.use(['table', 'form', 'jquery','common'], function() {
				let table = layui.table;
				let form = layui.form;
				let $ = layui.jquery;
				let common = layui.common;

				let MODULE_PATH = "operate/";

				let cols = [
					[{
							type: 'checkbox'
						},
						{
							title: '订单编号',
							field: 'order_id',
							align: 'center',
							width: 100
						},
						{
							title: '游戏名',
							field: 'game_id',
							align: 'center',
							templet:'<div>{{d.game.game_name}}</div>'
						},
						{
							title: '生产时间',
							field: 'create_time',
							align: 'center',


						},
						{
							title: '用户名',
							field: 'user_id',
							align: 'center',
							templet:'<div>{{d.user.user_name}}</div>'
						},
						{
							title: '订单金额',
							field: '￥'+'order_price',
							align: 'center',

						}

					]
				]
				table.render({
					elem: '#order-table',
					url: 'http://localhost:8080/dreamgame/order/query',
					page: true,
					cols: cols,
					skin: 'line',
					toolbar: '#order-toolbar',
					defaultToolbar: [{
						title: '刷新',
						layEvent: 'refresh',
						icon: 'layui-icon-refresh',
					}, 'filter', 'print', 'exports']
				});


				table.on('tool(order-table)', function(obj) {
					if (obj.event === 'remove') {
						window.remove(obj);
					} else if (obj.event === 'edit') {
						window.edit(obj);
					}
				});

				table.on('toolbar(order-table)', function(obj) {
					if (obj.event === 'add') {
						window.add();
					} else if (obj.event === 'refresh') {
						window.refresh();
					} else if (obj.event === 'batchRemove') {
						window.batchRemove(obj);
					}
				});

				form.on('submit(order-query)', function(data) {
					table.reload('order-table', {
						where: data.field
					})
					return false;
				});

				form.on('switch(order-enable)', function(obj) {
					layer.tips(this.value + ' ' + this.name + '：' + obj.elem.checked, obj.othis);
				});


				window.refresh = function(param) {
					table.reload('order-table');
				}
			})
		</script>
	</body>
</html>
